package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.common.DeliveryType;
import com.ap.core.cxf.jaxb.rtp.TransactionCheckOutType;
import com.ap.core.message.managepayment.info.ConfirmPaymentRequestMessageInfo;
import com.ap.core.validation.message.info.RTPOriginalInfoForConfirmPayment;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User:Rohit.Dixit
 * The element QkPayDeliveryAddress must be present only if TransactionCheckOutType is QuickPay and Delivery Type is Delivery to Address, otherwise it must not
 */
public class RV0013Rule extends AbstractValidationRule<MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfoForConfirmPayment>> {

	@Override
	public boolean validate(MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfoForConfirmPayment> infoObject) {
        boolean pass = false;
        if(TransactionCheckOutType.QKPACHK == infoObject.getOriginalInfo().getTransactionCheckOutType() &&  DeliveryType.DELTAD == infoObject.getOriginalInfo().getDeliveryType()){
            pass = null != infoObject.getBoundObject().getPaymtDetails().getQkPayDelAddress();
		}
        else {
            pass = null == infoObject.getBoundObject().getPaymtDetails().getQkPayDelAddress();
		}
		return pass;
	}

}

